
set scheme s1color

use repeated_cross_section_placebo.dta, clear

// muslim indicator
gen muslim=(paiperc=="06"|paiperc=="08")

// cluster variable
egen pbpl=group(paiperc)

// aggregate cohorts
* drop if birthyear>1980
gen cohort=1970 if birthyear==1970|birthyear==1971
replace cohort=1972 if birthyear==1972|birthyear==1973
replace cohort=1974 if birthyear==1974|birthyear==1975
replace cohort=1976 if birthyear==1976|birthyear==1977
replace cohort=1978 if birthyear==1978|birthyear==1979
replace cohort=1980 if birthyear==1980|birthyear==1981
replace cohort=1982 if birthyear==1982|birthyear==1983
replace cohort=1984 if birthyear==1984|birthyear==1985
replace cohort=1986 if birthyear==1986|birthyear==1987
replace cohort=1988 if birthyear==1988|birthyear==1989
replace cohort=1990 if birthyear==1990|birthyear==1991 
replace cohort=1992 if birthyear==1992|birthyear==1993

drop if cohort==.

local sample if pnai28=="10"  & female==1  
local cl pbpl
reg secondary i.ag i.surveyr `sample', cluster(`cl')   
predict resid, res
local var resid
collapse (mean) `var' (count) personid `sample', by(cohort muslim)

******************************************
expand 2
replace cohort = . if _n>(_N/2)
recode muslim (1=0) (0=1) if cohort==.
********************************************
twoway scatter `var'  cohort [aweight=personid] if muslim==1, msymbol(circle) mcolor(cranberry) legend(label(1 "Muslim") label(2 "Non-Muslim")) ///
 ||  scatter `var'  cohort [aweight=personid] if muslim==0, msymbol(circle_hollow) mcolor(dknavy) xline(1976, lcolor(gs10)) ///
 xtitle("Year of birth") ytitle("Completed secondary education | X")
